/**
 * 
 */
package tree;

import java.util.Stack;

/**
 * @author michaelyi
 *
 */
public class TreeNode<T> {

	public TreeNode<T> left = null;
	public TreeNode<T> right = null;
	public TreeNode<T> middle = null;
	public TreeNode<T> parent = null;
	public T data;
	
	/**
	 * 
	 */
	public TreeNode(T data) {
		this.data = data;
	}
	
	public TreeNode(T data, TreeNode<T> left, TreeNode right) {
		this.data = data;
		this.left = left;
		this.right = right;
	}
	
	@Override
	public boolean equals(Object o) {
		if (o == this)
			return true;
		if (!(o instanceof TreeNode))
			return false;
		@SuppressWarnings("unchecked")
		TreeNode<T> treeNode = (TreeNode<T>)o;
		return treeNode.data.equals(this.data);
	}
	
	@Override
	public int hashCode() {
		int result = 17;
		result = 31 * result + data.hashCode();
		return 0;
	}
	
	@Override
	public String toString() {
		return data.toString();
	}

}
